How to add addresses to hosts
To do this, right-click on the Finder icon on the bottom panel (Dock) of your computer and select "Go to folder..." from the drop-down menu.

In the window that opens, enter the path to the hosts file on computers with the OS X operating system and click the "Go" button. The path looks like this.

/private/etc/hosts

This will open a Finder window in the folder where the file you are looking for is located. It will already be selected. Just right-click on it and open it with your favorite text editor (the standard TextEdit will do).

The file itself is protected from editing. However, when you try to make changes, you will be prompted to create a copy of it - do so. Make the necessary changes to the copy of the file and save it, for example, on the desktop as a file called hosts. After that, delete the permission.txt from the saved file.

Next, you just need to replace the old hosts file with the newly created one by simply dragging it from the desktop to the folder where the original file is located. In the pop-up window, confirm the action by clicking the "Replace" button.

That's all. But sometimes, in order for the changes to take effect immediately, you may need to refresh the DNS cache. To do this, run the following command in the terminal (you will need to enter the administrator password)

dscacheutil -flushcache; sudo killall -HUP mDNSResponder

After this, the rules specified in the new hosts file will definitely work as they should.